<template>
	<view class="main">
		<image mode="aspectFill" class="img" src="/static/home.jpg" />
		<view class="list">
			<view class="left-item">
				<view class="inner" @click="navigateTo('/pages/enroll/index')">
					<image src="/static/menu/2.png"></image>
					<text>预定会议室</text>
				</view> 
			</view>
			<view class="right-items">
				<view class="item">
					<view class="inner" @click="navigateTo('/pages/calendar/index')">
						<image src="/static/menu/3.png"></image>
						<text>会议日历</text>
					</view> 
				</view>
				<view class="item" v-if="isLoggedIn">
					<view class="inner" @click="navigateTo('/pages/my/index')">
						<image src="/static/menu/4.png"></image>
						<text>我的预定</text>
					</view> 
				</view>
				<view class="item" v-else>
					<view class="inner" @click="navigateToLogin">
						<image src="/static/menu/4.png"></image>
						<text>登录</text>
					</view> 
				</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			isLoggedIn: false
		}
	},
	onShow() {
		// 检查登录状态
		this.checkLoginStatus();
	},
	methods: {
		checkLoginStatus() {
			// 检查是否有token
			const token = uni.getStorageSync('token');
			this.isLoggedIn = !!token;
		},
		navigateTo(url) {
			uni.switchTab({
				url: url
			})
		},
		navigateToLogin() {
			uni.navigateTo({
				url: '/pages/login/index'
			})
		}
	}
}
</script>

<style lang="less" scoped>
page {
	background-color: #fff;
}

.main {
	width: 100%;
	padding: 0;

	.img {
		width: 100%;
		height: 600rpx;
	}

	.list {
		position: relative;
		margin-top: -50rpx;
		background-color: #fff;
		display: flex;
		padding: 80rpx 40rpx 60rpx;
		border-top-right-radius: 50rpx;
		border-top-left-radius: 50rpx;
		justify-content: space-between;
		align-items: stretch;

		.left-item {
			width: 48%;
			height: 400rpx;
			display: flex;

			.inner {
				width: 100%;
				height: 100%;
				display: flex;
				flex-direction: column;
				justify-content: center;
				align-items: center;
				background-color: #F0F2FE;
				border-radius: 20rpx;
				transition: all 0.3s ease;
				box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.08);

				&:active {
					transform: scale(0.95);
					background-color: #E8EBFD;
				}

				image {
					width: 90rpx;
					height: 90rpx;
					margin-bottom: 20rpx;
				}

				text {
					font-size: 30rpx;
					color: #333;
					font-weight: 600;
					text-align: center;
				}
			}
		}

		.right-items {
			width: 48%;
			height: 400rpx;
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			overflow: hidden;

			.item {
				height: 180rpx;

				.inner {
					width: 100%;
					height: 100%;
					display: flex;
					flex-direction: column;
					justify-content: center;
					align-items: center;
					background-color: #F0F2FE;
					border-radius: 20rpx;
					transition: all 0.3s ease;
					box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.08);

					&:active {
						transform: scale(0.95);
						background-color: #E8EBFD;
					}

					image {
						width: 70rpx;
						height: 70rpx;
						margin-bottom: 12rpx;
					}

					text {
						font-size: 26rpx;
						color: #333;
						font-weight: 600;
						text-align: center;
					}
				}
			}
		}
	}
}
</style>
